package com.flick.user.ctrl;

import com.flick.annotation.AutoResult;
import com.flick.annotation.NotAutoResult;
import com.flick.common.CommonPage;
import com.flick.common.Result;
import com.flick.user.services.UserService;
import com.flick.vo.payment.UserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "用户相关")
@RequestMapping("/api/user")
@Slf4j
@AutoResult
public class UserCtrl {

    @Autowired
    UserService service;

    @ApiOperation("测试列表")
    @GetMapping("/list")
    public List<UserVo> list(){
        return service.list();
    }

    @ApiOperation("测试分页")
    @GetMapping("/page")
    public CommonPage<UserVo> page(@ApiParam(value="page",defaultValue = "1",required = true,example = "1") @RequestParam Integer page,
                                   @ApiParam(value="size",defaultValue = "10",required = true,example = "10") @RequestParam Integer size){
        return service.page(page,size);
    }

    @ApiOperation("测试保存(默认3秒)")
    @PostMapping()
    @NotAutoResult
    public Result save(@ApiParam(value="sec",defaultValue = "3",required = true,example = "3") @RequestParam Integer sec){
        return service.save(sec);
    }
}
